package com.vita.testCore1.Data;

import java.util.UUID;

/**
 * 数值仓库
 * 每一个执行器都应该继承自该类
 * @param <I> 输入参数类型
 * @param <O> 输出参数类型
 */
public abstract class ValueStore<I,O> implements CvtMetaInfo{
    private final static String KEY = "ValueStore";
    private String id;

    private com.vita.testCore.value.ValueStore<I,O> value;

    {
        id = UUID.randomUUID().toString().replaceAll("-","");
    }

    public com.vita.testCore.value.ValueStore<I,O> getInfo(){
        return this.value;
    }

    public void input(I input){
        if(value == null){
            this.value = new com.vita.testCore.value.ValueStore<I,O>(input);
        }else {
            this.value.setInput(input);
        }
    }

    public void output(O output){
        if(value == null){
            throw new ClassCastException("input缺省");
        }else {
            this.value.setOutput(output);
        }
    }

    public <C> void output(C context,O output){}

    @Override
    public String getKey() {
        return KEY;
    }

    @Override
    public String getId() {
        return id;
    }
}
